package com.ruoyi.api.utils;

import com.itmuch.lightsecurity.jwt.JwtOperator;
import com.itmuch.lightsecurity.jwt.User;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class JwtUtils {
    @Value("light-security.jwt.secret")
    public String secret;

    @Autowired
    private JwtOperator operator;

    public String getIdByToken(String token){
        Claims claims = operator.getClaimsFromToken(token);
        return (String) claims.get("username");
    }
}
